package com.example.designsoft.basetest;

import android.app.Activity;
import android.os.Bundle;

import androidx.annotation.Nullable;

import com.example.designsoft.util.GetClassUtils;

/**
 * author : Gyk
 * time   : 2020/11/18
 * todo   :
 */
public abstract class BaseActivity<P extends BasePresenter, M extends BaseModel> extends Activity {

    public  P mPresenter;
    public  M mModel;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(getLayoutResId());
        mPresenter = GetClassUtils.getT(this,0);
        mModel = GetClassUtils.getT(this,1);
        mPresenter.onAttachModelAndView(mModel,this);
        initData();
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        mPresenter.onDettach();
    }

    public abstract void initData();

    public abstract int getLayoutResId();
}
